package edu.ut.ece382c.valloy.parser;

import java.util.LinkedList;
import java.util.Vector;

import edu.mit.csail.sdg.alloy4.Pos;

public class ValloyClass {
	private ValloyClass parent = null;
	private String label = null;
	private Vector<String> virtualFuns = null;
	private LinkedList<ValloyClass> children = null;
	private Pos position;
	
	public ValloyClass (String name, ValloyClass parentClass){
		this.parent = parentClass;
		this.label = name;
		this.virtualFuns = new Vector<String>();
		this.children = new LinkedList <ValloyClass> ();
	}

	public ValloyClass getParent() {
		return parent;
	}

	public String getName() {
		return label;
	}
	
	public LinkedList<ValloyClass> getChildren() {
		return children;
	}
	public Vector<String> getVirtualFuns() {
		return virtualFuns;
	}
	public void addChild (ValloyClass node){
		children.add(node);
	}
	public Pos setPosition(Pos pos){
		return position = pos;
	}
	public Pos getPosition(){
		return position;
	}
	

	@Override
	public String toString() {
		String out = "";
		out+= "\nVAlloy class Name: " + label + "\n";
		out+= "Parent: " + (parent!=null?parent.getName():"None") + "\n";
		out+= "Children: " +children.toString() + "\n";
		return out;
	}
	public String nodeTreePrint(String buffer, int level) {
		buffer += "//";
		for (int i = 1;i<level;i++)
			buffer += "|  ";
		buffer += level>0?"+--":"";
		//buffer += (children.size()==0?"-":"+") + label + "\n";
		buffer += label + "\n";
		
		for (ValloyClass child: children){
				buffer = child.nodeTreePrint(buffer, level +1);
			}
		return buffer;
	}
}
